package com.xyq.friend.controller.question;

import com.xyq.common.core.constants.HttpConstants;
import com.xyq.common.core.controller.BaseController;
import com.xyq.common.core.domain.Result;
import com.xyq.friend.aspect.CheckStatus;
import com.xyq.friend.domain.user.dto.UserSubmitDTO;
import com.xyq.friend.service.question.UserQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/question")
public class UserQuestionController extends BaseController {

@Autowired
private UserQuestionService userQuestionService ;
    @CheckStatus

    @PostMapping("/submit")
    public Result submit(@RequestBody UserSubmitDTO userSubmitDTO , @RequestHeader(HttpConstants.AUTHENTICATION) String token){

        return userQuestionService.submit(userSubmitDTO , token) ;
    }
    @CheckStatus

    @PostMapping("/rabbit/submit")
    public Result rabbitSubmit (@RequestBody UserSubmitDTO userSubmitDTO ){

        return toResult(userQuestionService.rabbitSubmit(userSubmitDTO)) ;
    }

    @CheckStatus

    @GetMapping("/judgeResult")
    public Result judgeResult(Long questionId , Long examId, String currentTime){
        return Result.success(userQuestionService.judgeResult(questionId , examId, currentTime)) ;
    }

}

